// RenderToFileDialog.cpp : implementation file
//

#include "stdafx.h"
#include "CGWork.h"
#include "RenderToFileDialog.h"
#include "afxdialogex.h"


// RenderToFileDialog dialog

IMPLEMENT_DYNAMIC(RenderToFileDialog, CDialogEx)

	RenderToFileDialog::RenderToFileDialog(int width, int height, CWnd* pParent /*=NULL*/)
	: CDialogEx(RenderToFileDialog::IDD, pParent)
	, width(width)
	, height(height)
	, filename(_T(""))
{

}

RenderToFileDialog::~RenderToFileDialog()
{
}

void RenderToFileDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, width);
	DDV_MinMaxInt(pDX, width, 1, 100000000);
	DDX_Text(pDX, IDC_EDIT4, height);
	DDV_MinMaxInt(pDX, height, 1, 100000000);
	DDX_Text(pDX, IDC_EDIT2, filename);
	DDX_Control(pDX, IDC_EDIT2, filename_edit);
}


BEGIN_MESSAGE_MAP(RenderToFileDialog, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON1, &RenderToFileDialog::OnBrowseButtonClicked)
END_MESSAGE_MAP()


// RenderToFileDialog message handlers


void RenderToFileDialog::OnBrowseButtonClicked()
{
	TCHAR szFilters[] = _T ("PNG Files (*.png)|*.png|All Files (*.*)|*.*||");
	CFileDialog dlg(false, "png", "*.png", OFN_HIDEREADONLY ,szFilters);
	if(dlg.DoModal() == IDOK)
	{
		filename = dlg.GetPathName();
		filename_edit.SetWindowTextA(filename);
	}

}
